package com.kla.power.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kla.power.entity.*;
import com.kla.power.mapper.LatestInverterElectricMapper;
import com.kla.power.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 逆变器发电数据 服务实现类
 * </p>
 * @author WuZH
 * @since 2024-06-02
 */
@Slf4j
@Service
public class LatestInverterElectricServiceImpl extends ServiceImpl<LatestInverterElectricMapper, LatestInverterElectricEntity> implements ILatestInverterElectricService {

    @Override
    public void saveOrUpdateSingle (InverterElectricEntity inverterElectricEntity) {
        log.info ( "同步更新最新发电数据：{}", JSON.toJSON ( inverterElectricEntity ) );
        //防止4G发送错误数据，这里根据制造商名称是否为"艾伏"进行筛选入库
        LatestInverterElectricEntity latestInverterElectricEntity = new LatestInverterElectricEntity ();
        BeanUtils.copyProperties ( inverterElectricEntity, latestInverterElectricEntity );
        this.getBaseMapper ().saveOrUpdateSingle ( latestInverterElectricEntity );
    }
}
